<template>
  <el-dialog
    :visible.sync="dialogVisible"
    :before-close="handleClose"
    :close-on-click-modal="false"
    :title="title"
    width="60%">
    <dynForm
      ref="dataForm"
      :info-form="infoForm"
      :search-tags="searchTags"
    />
    <span slot="footer">
      <el-button
        icon="el-icon-circle-close"
        @click="handleClose"
      >{{ $t("cancel") }}</el-button>
      <el-button
        v-btnThrottle="doSave"
        type="primary"
        icon="el-icon-receiving"
      >{{ $t("save") }}</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  name: 'ModelJobAbort',
  data() {
    const searchTags = [
      { label: this.$t('eqpName'), prop: 'eqpName', tag: 'DynInput', disabled: true },
      { label: this.$t('LotNumebr'), prop: 'LotNumebr', tag: 'DynInput', disabled: true },
      { label: this.$t('operator'), prop: 'operator', tag: 'DynInput', disabled: true },
      { label: this.$t('Reason'), prop: 'reason', tag: 'DynInput' }
    ]
    return {
      dialogVisible: false,
      title: '',
      infoForm: {},
      selectList: {},
      searchTags: Object.freeze(searchTags)
    }
  },
  methods: {
    async handleOpen(row) {
      this.title = this.$t('add')
      this.dialogVisible = true
    },
    doSave() {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          if (this.infoForm.id) {
            // doUpdate(this.$clearNull({ ...this.infoForm, sblSpecList: filtertable })).then(res => {
            //   this.$betterTips(res, this.handleClose, this.handleUpdate)
            // })
          } else {
            // doAdd(this.$clearNull({ ...this.infoForm, sblSpecList: filtertable })).then(res => {
            //   this.$betterTips(res, this.handleClose, this.handleUpdate)
            // })
          }
        }
      })
    },
    handleClose() {
      Object.assign(this.$data, this.$options.data.call(this))
    },
    handleUpdate() {
      this.$emit('initList')
    }
  }
}
</script>
